/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-06-15     xingwenbo       the first version
 */
#ifndef SRC_USER_QUEUE_H_
#define SRC_USER_QUEUE_H_

#include <rtthread.h>
#include "stdint.h"


struct user_queue_u8
{
    rt_uint8_t *buf;
    rt_uint16_t len;
    rt_uint16_t head;
    rt_uint16_t end;
};

uint16_t user_queue_u8_get_size(struct user_queue_u8 *queue);
uint8_t user_queue_u8_is_full(struct user_queue_u8 *queue);
uint8_t user_queue_u8_is_empty(struct user_queue_u8 *queue);

void user_queue_u8_init(struct user_queue_u8 *queue,uint8_t *buf,uint16_t len);
void user_queue_u8_putchar(struct user_queue_u8 *queue,uint8_t data);
uint8_t  user_queue_u8_getchar(struct user_queue_u8 *queue);
uint8_t  user_queue_u8_readchar(struct user_queue_u8 *queue,uint16_t offset);
void user_queue_u8_clear(struct user_queue_u8 *queue);

uint16_t user_queue_u8_put(struct user_queue_u8 *queue,uint8_t *data,uint16_t length);
uint16_t user_queue_u8_get(struct user_queue_u8 *queue,uint8_t *data,uint16_t length);
void user_queue_u8_headmove(struct user_queue_u8 *queue,int offset_len);
void user_queue_u8_endmove(struct user_queue_u8 *queue,int offset_len);

#endif /* SRC_USER_QUEUE_H_ */
